#ifndef SOLUTION_H_
#define SOLUTION_H_
struct ListNode
{
	int val;
	ListNode* next;
	ListNode(int v):val(v),next(NULL){}
	/*bool operator<=(const ListNode* node)
	{
		return val>=node->val;
	}*/
};

class Solution {
public:
    ListNode *mergeTwoLists(ListNode *l1, ListNode *l2) {
        // Start typing your C/C++ solution below
        // DO NOT write int main() function
		if(!l1)
			return l2;
		else if(!l2)
			return l1;

		ListNode head(0);
		ListNode* cur = &head, *c1 = l1, *c2 = l2;
		while(c1 && c2)
		{
			if(c1->val <= c2->val)
			{
				cur->next = c1;
				c1 = c1->next;
			}
			else
			{
				cur->next = c2;
				c2 = c2->next;
			}
			cur = cur->next;
		}

		if(!c1)
			cur->next = c2;
		else
			cur->next = c1;

		return head.next;
    }
};
#endif